﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Hallenberg.SmartClient.Menu;

namespace Hallenberg.SmartClient.Test.Menu
{
    [TestFixture]
    public class MenuItemContainerTest
    {
        private const string MenuName = "MainMenu";
        private MenuItemContainer menuItemContainer;

        [SetUp]
        public void PerTestSetup()
        {
            menuItemContainer = new MenuItemContainer(MenuName);
        }

        [Test]
        public void ShouldBeAbleToAddMenuItem()
        {
            Assert.That(menuItemContainer.MenuItemName, Is.EqualTo(MenuItemContainer.MenuManagerRootId));
        }

        [Test]
        public void ShouldBeAbleToCreateMenuItemContainer()
        {
            const string MenuItemName = "The Menu Item Name";
            const string MenuItemTitle = "The Menu Item Title";
            const string ToolTip = "The Tooltip";

            menuItemContainer.AddMenuItem(new MenuItem(MenuItemName, MenuItemTitle, ToolTip));

            Assert.That(menuItemContainer.ChildItems.Count, Is.EqualTo(1));
        }

        [Test]
        public void ShouldBeAbleToSortMenuItems()
        {
            const string MenuItemNameOne = "The First Menu Item Name";
            const string MenuItemTitleOne = "The First Menu Item Title";
            const string ToolTipOne = "The First Tooltip";

            const string MenuItemNameTwo = "The First Menu Item Name";
            const string MenuItemTitleTwo = "The First Menu Item Title";
            const string ToolTipTwo = "The First Tooltip";

            menuItemContainer.AddMenuItem(new MenuItem(MenuItemNameOne, MenuItemTitleOne, ToolTipOne) { SortIndex = 200 });
            menuItemContainer.AddMenuItem(new MenuItem(MenuItemNameTwo, MenuItemTitleTwo, ToolTipTwo) { SortIndex = 100 });

            Assert.That(menuItemContainer.ChildItems.Count, Is.EqualTo(2));
            Assert.That(menuItemContainer.ChildItems[0].MenuItemName, Is.EqualTo(MenuItemNameTwo));
            Assert.That(menuItemContainer.ChildItems[1].MenuItemName, Is.EqualTo(MenuItemNameOne));
        }
    }
}
